<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <title>
        </title>
        <link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.1.1/jquery.mobile-1.1.1.min.css" />
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
        </script>
        <script src="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.1.1/jquery.mobile-1.1.1.min.js">
        </script>
		<script src="scripts/utils.js">
        </script>
		
        <script>
            $(document).ready(function(){
				var studentId = getUrlParam('studentId');
				var personalId = getUrlParam('personalId');
				
				loadStudent(studentId, personalId);
            });
			
			function loadStudent(studentId, personalId) {
				$.ajax({
                url: "http://78.90.20.249:8888/rest/student-info/" + studentId + "/" + personalId,
                type: "GET",
                timeout: 5000,
                dataType: "json",
                success:
                    function (student) {
						$('#studentId').html(student.studentId);
						$('#personalId').html(student.personalId);
						$('#firstName').html(student.firstName);
						$('#lastName').html(student.lastName);
						$('#group').html(student.group);
						$('#potok').html(student.potok);
						$('#faculty').html(student.faculty);
						$('#semester').html(student.semester);
						$('#headerName').html(student.firstName + ' ' + student.lastName);
                    },
                error:
                    function (err) {
                        alert("error: " + err.status);
                    }
				});
			}
			
			function goToGrades() {
				alert('goToGrades');
				var studentId = $('#studentId').val();
				alert(studentId);
                window.location='Grades.html?studentId=' + studentId;
			}
        </script>
    </head>
    <body>
            <div>
                <ul data-role="listview" data-divider-theme="b" data-inset="false">
                    <li data-role="list-divider" role="heading">
                        Hello, <span id="headerName"/>
                    </li>
					<li>
                        Student Info

                        <table cellspecing=0 cellpadding=5>
                            <tr>
                                <td><p>StudentID: <span id="studentId"/> </p></td>
                                <td><p>PersonalID: <span id="personalId"/></p></td>
                            </tr>
							<tr>
								<td><p>First Name: <span id="firstName"/></p></td>
								<td><p>Last Name: <span id="lastName"/></p></td>
							</tr>
							<tr>
								<td><p>Group: <span id="group"/></p></td>
								<td><p>Potok: <span id="potok"/></p></td>
							</tr>
							<tr>
								<td><p>Faculty: <span id="faculty"/></p></td>
								<td><p>Semester: <span id="semester"/></p></td>
							</tr>
                        </table>
						
                    </li>
                    <li data-theme="c">
                        <a onclick="window.location='Grades.html?studentId=' + getUrlParam('studentId');" data-transition="slide">
                            Grades
                        </a>
                    </li>
                    <li data-theme="c">
                        <a onclick="window.location='Attendances.html?studentId=' + getUrlParam('studentId');" data-transition="slide">
                            Attendances
                        </a>
                    </li>
                    <li data-theme="c">
                        <a onclick="window.location='http://78.90.20.249:8888/pdf?potok=' + potok.innerText;" data-transition="slide">
                            Program
                        </a>
                    </li>
                    <li data-theme="c">
                        <a onclick="window.location='MAP.html'" data-transition="slide">
                            TU Map
                        </a>
                    </li>
                    <li data-theme="c">
                        <a onclick="window.location='TU_INFO_TAB.html'" data-transition="slide">
                            Info for TU
                        </a>
                    </li>
                </ul>
            </div>
    </body>

</html>